package com.example.config;

import com.example.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfiguration implements WebMvcConfigurer {

    @Override   //拦截器配置
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()) //拦截器注册对象
                .addPathPatterns("/**") //指定要拦截的请求
                .excludePathPatterns("/login", "/css/**", "/imgs/**", "/layui/**", "/tologin", "/tovxlogin", "/user/register"
                        , "/category/getAllCategory", "/commodity/getCommodityByCategoryId", "/commodity/getCommodityById", "/commodity/getAllCommodity"
                        , "/commodity/getCount", "/commodity/getCommodityByName", "/category/getAllCategoryName", "/commodity/upload"
                        , "/commodity/publishCommodity", "/post/getAllPost", "/post/publishPost", "/commodity/getAllPublish"
                        , "/commodity/getAllBuy", "/commodity/confirm", "/post/getPublishPost", "/user/edit", "/commodity/buy",
                        "/commodity/delete", "/post/delete", "/user/editPassword", "/user/publishCount", "/user/buyCount"
                ); //排除请求

    }
}